<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class ACL {
   // public $roll = array(); 
    public $key ;
    public $value ;
    private static $_instance ; 
    public static function callMethod(){
        self::$_instance = new self ;
        return self::$_instance;
    }
    public function defineAuthor($author){
        $this->key = $author;
        return $this;
    }
    public function defineAuthorRole($val){
        $this->value = $val;
        return $this;
    }
    public function bindRoll() {
        global $roll  ;
        $roll  = array();
        array_push($roll[$this->key]=$this->value);
    }
    public function bindArrayToObject($array) {
        
	$return = new stdClass();
	foreach ($array as $k => $v) {
		if (is_array($v)) {
			$return->$k = $this->bindArrayToObject($v);
		}
		else {
			$return->$k = $v;
		}
	}
       
	return $return;
    }
    public function getRoll($type = NULL){
        if($type == NULL){
          
            return $roll;
        } else {
            if(array_key_exists($type, $this->roll)){
                return $roll[$type];
             }  else {
                 return new Exception ($type ." is Not exists.");
             }
        }
    }
}
f
/*$acl = new ACL();


$user = "designer";
$rolls = array("login"=>array("login"=>"yes")
        );
$roll2 = "dataentry";
$rollArray = array("acemodle"=>array("insert"=>"yes",
                                     "edit"=>"yes",
                                     "active&inactive"=>"yes"
                                    ),
                  "billing"=>array("insert"=>"yes",
                                     "edit"=>"yes",
                                     "active&inactive"=>"yes"
                                    )
                   );
  $acl->defineAuthor($user)->defineAuthorRole($rollArray)->bindRoll();
  
  
  
echo '<pre>';
print_r($roll);
$rollobj = bindArrayToObject($roll);


//print_r($rollobj->designer->acemodle->insert);
  //echo json_encode($acl->getRoll());
//$acl->defineAuthor($user)->defineAuthorRole($roll)->bindRoll();
//$acl->defineAuthor($roll2)->defineAuthorRole($rollArray)->bindRoll();

*/



//echo str_replace("_",DIRECTORY_SEPARATOR ,ROOT.strtolower($class))."/$class.php";
//print_r($roles1);


?>
